Technical Q&As

OPS 14 - Determining if a 680x0 program is Running on a PPC (27-September-96)


Q How do I determine if my 68K program is running on a PPC?

A The best way to do this is to use the Gestalt Selectors as described in the Universal Interface file Gestalt.h:
enum {
	gestaltSysArchitecture = 'sysa',   /* Native System Architecture */
	gestalt68k	= 1,	               /* Motorola MC68k architecture */
	gestaltPowerPC	= 2                /* IBM PowerPC architecture */
};

A snippet of code that uses this could look something like this in your 68K program:

#include <gestalt.h>#include <stdio.h>#include <Types.h>     long myattr;
    OSErr err;
  	err = Gestalt( gestaltSysArchitecture, &myattr;);
 	if (err == noErr) {
		if (myattr == gestaltPowerPC) {
			InstallExtraPPCComp();
		}
	} else {
		// handle error condition
	}


Technical Q&As
Previous Question | Contents | Next Question